import { RoleEntity } from '../entities/role.entity';
import { Resolver, Mutation, Args, Query } from '@nestjs/graphql';
import { MutationRes } from 'src/modules/shared/vo/mutation.res';
import { RoleService } from '../services/role/role.service';

@Resolver('Role')
export class RoleResolver {
  constructor (
    private readonly roleService: RoleService,
  ) { }

  @Mutation(() => MutationRes, { description: '创建角色' })
  async createRole(
    @Args('name') name: string
  ): Promise<MutationRes> {
    return await this.roleService.createRole(name);
  }

  @Query(() => [RoleEntity!]!, { description: '返回角色列表' })
  async roleList(): Promise<RoleEntity[]> {
    return await this.roleService.roleList();
  }
}
